import { createBehavior, createResource } from '@inbiz/core';
import { LogManagement  } from './locale'
import {
  createInbizSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
  getDefalutDecoratorProps,
} from '@inbiz/setters';
import { getPlatform } from '@inbiz/utils';


export const puredynamicdata = [
  {
    id: 'searchLog',
    title: 'LogManagement.searchLog',
    isEdit: true,
    isHide: true,
    isDel: false,
    icon: {
      size: 40,
      type: 'icon-faqishenqing',
      color: '#3280fc',
    },
    externalAddress: false,
    linkAddress: '',
    page: '',
    blockBackgroundColor: 'rgba(50,128,252,1)',
    titleColor: 'rgba(0,0,0,1)',
    hintNumberColor: 'rgba(0,0,0,1)',
    gridHeight: 80,
    gridNum: 6,
    count: 0,
    hintNumberFontSize: 14,
  },
  {
    id: 'issueAnalysisLog',
    title: 'LogManagement.problemLog',
    isEdit: true,
    isHide: true,
    isDel: false,
    icon: {
      size: 40,
      type: 'icon-faqishenqing',
      color: '#3280fc',
    },
    externalAddress: false,
    linkAddress: '',
    page: '',
    blockBackgroundColor: 'rgba(50,128,252,1)',
    titleColor: 'rgba(0,0,0,1)',
    hintNumberColor: 'rgba(0,0,0,1)',
    gridHeight: 80,
    gridNum: 6,
    count: 0,
    hintNumberFontSize: 14,
  }
];
export const defaultProps = {
  pagesNum:'20条/页',
  puredynamicdata,
  style: {
    padding: '22px 20px 0px 20px',
  },
};

export const Schema = {
  droppable: false,
  propsSchema: createInbizSchema({
    attribute: {
      base: {
        type: 'void',
        'x-component': 'CollapseItem',
        properties: {

          'x-display': {
            type: 'string',
            enum: ['visible', 'hidden'],
            'x-decorator': 'FormItem',
            'x-component': 'Select',
            'x-component-props': {
              defaultValue: 'visible',
            },
          },

          'x-component-props': {
            type: 'object',
            properties: {
              pagesNum: {
                type: 'string',
                'x-decorator': 'FormItem',
                'x-component': 'Select',
                enum: [10,20, 30, 50, 100],
              },
              puredynamicdata: {
                type: 'array',
                'x-decorator': 'FormItem',
                'x-component': 'DataSource',
                // 根据配置显示
                'x-component-props': {
                  config: {
                    title: true,
                    hideAddBtn: true,
                    isHide:true
                  },
                  // 新建时表单默认值
                  default: {
                    processGroup: true,
                  },
                  defaultValue: puredynamicdata,
                },

                platform: 'web',
              },
            },
          },
        },
      },
    },
    style: {
      ...createComponentStyleSchema({
      }),
      ...createDecoratorStyleSchema(),
    },

  }),
};

export const Behavior = createBehavior({
  extends: ['Field'],
  name: 'LogManagement',
  selector: (node) => node.props?.['x-component'] === 'LogManagement',
  designerLocales: LogManagement,
  designerProps: Schema,
});

export const Resource = createResource({
  icon: 'LogManagement',
  elements: [
    {
      componentName: 'Field',
      props: {
        title: {
          status: true,
          value: 'LogManagement.title',
        },
        type: 'string',
        'x-decorator': 'Container',
        'x-component': 'LogManagement',
        'x-component-props': defaultProps,
        'x-decorator-props': getDefalutDecoratorProps(getPlatform(), { border: false }, { padding: '22px 20px 0px 20px' }),
      },
    },
  ],
});
